﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using System.Web;
using Antu.WorkFlowFactory;
using System.Data;

namespace WebSys.UI.OfficeFlow
{
    public class UserGrouplistSkin : MPBasicTemplate
    {
        FlowFactoryProvider _FlowFactoryProvider = (FlowFactoryProvider)ProviderService.ProviderServiceMange.GetProvider("FlowFactoryProvider");
        Button btnQuery;
        TextBox txtSeach;
        MPRepeater MPRepeater1;
        protected string UserId
        {
            get { if (base.Page.Session["UserId"] != null) { return base.Page.Session["UserId"].ToString(); } else { return string.Empty; } }
            set { base.Page.Session["UserId"] = value; }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            InitControl();
            if (!Page.IsPostBack)
            {
                
                BindData();
            }
            string strGroupID = base.Page.Request["groupid"];
            string action = base.Page.Request["action"];
            if (action == "del") {
                if (!string.IsNullOrEmpty(strGroupID))
                {
                    bool del = _FlowFactoryProvider.DeleteTableRow("st_group", "GROUPID", strGroupID);
                    if (del) { Antu.Utilities.UtilitiesPage.AlertDialog("删除成功!", "window.location.href=window.location.href;"); }
                }
            }
        }
        private void InitControl()
        {
            txtSeach = (TextBox)FindControl("txtSeach");
            btnQuery = (Button)FindControl("btnQuery");
            btnQuery.Click += new EventHandler(btnQuery_Click);
            MPRepeater1 = (MPRepeater)FindControl("MPRepeater1");
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            BindData();
        }
        protected void BindData() {
            string userName = txtSeach.Text;
            DataTable dt = _FlowFactoryProvider.GetAllGroupInfo(userName);
            MPRepeater1.DataSource = dt;
            MPRepeater1.DataBind();
        }


    }
}


